package top.cdmrx.oss.control;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import top.cdmrx.common.R;
import top.cdmrx.oss.service.OssService;

/**
 * Created by Mr.陈 time on 2021/9/12 | 14:46
 **/
@RestController
@RequestMapping("/eduoss/oss")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 上传头像文件服务
     * @param file
     * @return
     */
    @PostMapping
    public R uploadOssFile(MultipartFile file){

        String url = ossService.uploadFileAvatar(file);

        return R.success().data("url",url);
    }
}
